package com.nomi.blog.controller;

import com.nomi.blog.service.FollowingService;
import com.nomi.blog.utils.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/following")
public class FollowingController {
    @Autowired
    private FollowingService followingService;

    /**
     * 关注用户
     * @param userId
     * @param followingUserId
     * @return
     */
    @PostMapping("/follow")
    public Result followUser(@RequestParam Long userId, @RequestParam Long followingUserId) {
        return followingService.followUser(userId, followingUserId);
    }

    /**
     * 取消关注
     * @param userId
     * @param followingUserId
     * @return
     */
    @PostMapping("/unfollow")
    public Result unfollowUser(@RequestParam Long userId, @RequestParam Long followingUserId) {
        return followingService.unfollowUser(userId, followingUserId);
    }

    /**
     * 获取关注列表
     * @param userId
     * @return
     */
    @GetMapping("/list/{userId}")
    public Result getFollowingList(@PathVariable Long userId) {
        return followingService.getFollowingList(userId);
    }
}